<template>
  <div class="profile-page">
    <el-page-header @back="$router.back()" content="个人设置" class="header">
    </el-page-header>
    <el-row>
      <el-col :span="18">
        <el-form ref="form" :model="userInfo" label-width="80px">
          <el-form-item label="编号: ">{{ userInfo.id }}</el-form-item>
          <el-form-item label="手机: ">{{ userInfo.mobile }}</el-form-item>
          <el-form-item label="媒体名称: ">
            <el-input v-model="userInfo.name" class="profile-input"></el-input>
          </el-form-item>
          <el-form-item label="媒体介绍: ">
            <el-input type="textarea" v-model="userInfo.intro" class="profile-input"></el-input>
          </el-form-item>
          <el-form-item label="邮箱: ">
            <el-input v-model="userInfo.email" class="profile-input"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onKeep">保存设置</el-button>
          </el-form-item>
        </el-form></el-col
      >
      <el-col :span="6" class="cover">
        <el-avatar
          shape="square"
          :size="150"
          fit="cover"
          :src="userInfo.photo"
        ></el-avatar>
        <p @click="$refs.file.click()" class="update-img">修改图片</p>
        <input type="file" hidden ref="file" />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { GetUserInfo } from "@/services/user";

export default {
  name: "",
  data() {
    return {
      userInfo: {},
    };
  },
  created() {
    this.loadUserInfo();
  },
  methods: {
    loadUserInfo() {
      GetUserInfo().then((res) => {
        console.log(res);
        this.userInfo = res.data.data;
      });
    },
    onKeep() {
      this.$message({
        type: "success",
        message: "保存成功",
      });
    },
  },
};
</script>

<style scoped>
.profile-page {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-bottom: 25px;
}

.header {
  border-bottom: 1px solid #eee;
  padding-bottom: 20px;
  margin-bottom: 20px;
}

.profile-input {
  width: 60%;
}

.cover {
  position: relative;
}

.cover .update-img {
  cursor: pointer;
  position: absolute;
  bottom: -30px;
  left: 50px;
  font-size: 12px;
}
</style>
